#include <bits/stdc++.h>
using namespace std;

const int N = 1e3 + 5;
int directions[N], rivers[N][2], vi[N];
int n, m, k, now, top;

int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        cin >> rivers[i][0] >> rivers[i][1];

    for (int i = 1; i <= m; i++)
    {
        char c;
        cin >> c;
        directions[i] = (c == 'R') ? 1 : 0;
    }

    now = 1;
    while (!vi[now])
    {
        vi[now] = ++top;
        for (int i = 1; i <= m; i++)
            now = rivers[now][directions[i]];
    }

    int cycle_length = top - vi[now] + 1;
    int cycle_start = vi[now] - 1;
    k -= cycle_start;
    k %= cycle_length;

    while (k--)
    {
        for (int i = 1; i <= m; i++)
            now = rivers[now][directions[i]];
    }

    cout << now;
    return 0;
}
